package com.eqdd.yiqidian.ui.discover.workdiary;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.eqdd.annotation.datasave.DealCodeClass;
import com.eqdd.yiqidian.base.Config;
import com.eqdd.yiqidian.bean.EnterBean;
import com.eqdd.yiqidian.box.ItemDecoration.DividerLineItemDecoration;
import com.eqdd.yiqidian.ui.base.BaseEnterActivity;
import com.eqdd.yiqidian.ui.gongneng.renshi.meeting.MeetingNoticeListActivity;
import com.eqdd.yiqidian.ui.tongxunlu.stafftree.StaffTreeSingleActivity;
import com.eqdd.yiqidian.utils.ToastUtil;

/**
 * 工作动态
 * Created by jhj on 18-5-5.
 */

public class WorkNewsActivity extends BaseEnterActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        isDealCode = true;
        isRxbus = true;
        super.onCreate(savedInstanceState);
    }

    @DealCodeClass(classes = {MyWorkDiaryActivity.class})
    public void updateWorkDiary(int num) {
        updateNum(0, num);
    }


    @Override
    public void itemClick(int p) {
        Class clazz = enterBeans.get(p).getClazz();
        Intent intent = enterBeans.get(p).getIntent();
        if (clazz != null) {
            startActivity(clazz);
        } else if (intent != null) {
            startActivity(intent);
        } else {
            ToastUtil.showShort("该模块暂未开发");
        }
    }

    @Override
    public void initEnterData() {
        initTopTitleBar(View.VISIBLE, "工作动态");
        Intent intent;
        enterBeans.add(new EnterBean("我的日志").setClazz(MyWorkDiaryActivity.class));
        if (user.isIsleader()) {
            intent = new Intent(this, StaffTreeSingleActivity.class);
            intent.putExtra(Config.TYPE, StaffTreeSingleActivity.TYPE_DEPARTMENT_DIARY);
            intent.putExtra(Config.ID, user.getDepartId());
            intent.putExtra(Config.TITLE, user.getDepartment());
            enterBeans.add(new EnterBean("部门日志").setIntent(intent));
        }
        if (user.getIsAdmin() == 2) {
            enterBeans.add(new EnterBean("企业日志").setClazz(LeaderWorkDiaryActivity.class));
        }
        enterBeans.add(new EnterBean("工作日志").setClazz(PublicWorkDiaryActivity.class));
        enterBeans.add(new EnterBean("企业动态").setClazz(CompanyDynamicActivity.class));
        enterBeans.add(new EnterBean("当日任务").setClazz(TodayTaskActivity.class));
        intent = new Intent(this, MeetingNoticeListActivity.class);
        intent.putExtra(Config.TYPE, 1);
        enterBeans.add(new EnterBean("会议通知").setIntent(intent));
        dataBinding.recyclerView.addItemDecoration(new DividerLineItemDecoration(this));
    }

    @Override
    protected void lastRun() {
        super.lastRun();
        ((WorkNewsActivity$$DealCodeInjector) register).update1();
    }
}
